﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DataLibrary
{
    public class Ctbl_FunctionProduct:IData<tbl_FunctionProduct>
    {
        public Ctbl_FunctionProduct(String myconnecString) : base(myconnecString) { }


        

        public override List<tbl_FunctionProduct> GetAll(tbl_FunctionProduct item)
        {
            throw new NotImplementedException();
        }

        public override tbl_FunctionProduct GetItemById(object id)
        {
            return GetAll().SingleOrDefault(p => p.FunctionID == Convert.ToInt32(id));
        }

        public override tbl_FunctionProduct GetItem(IDataReader dr)
        {
            tbl_FunctionProduct obj = new tbl_FunctionProduct();
            obj.DetailContent = Convert.ToString(dr[tbl_FunctionProduct.c_DetailContent]);
            obj.FunctionID = Convert.ToInt32(dr[tbl_FunctionProduct.c_FunctionID]);
            obj.FunctionName = Convert.ToString(dr[tbl_FunctionProduct.c_FunctionName]);
            obj.ImageUrlTab = Convert.ToString(dr[tbl_FunctionProduct.c_ImageUrlTab]);
            obj.IsActive = Convert.ToInt32(dr[tbl_FunctionProduct.c_isActive]);
            obj.IsAddControl= Convert.ToBoolean(dr[tbl_FunctionProduct.c_IsAddControl]);
            obj.OrderId = Convert.ToInt32(dr[tbl_FunctionProduct.c_orderId]);
            obj.Title = Convert.ToString(dr[tbl_FunctionProduct.c_Title]);
            obj.Width = Convert.ToInt32(dr[tbl_FunctionProduct.c_Width]);
            return obj;
        }

        public override List<tbl_FunctionProduct> GetAll()
        {
            String strSQL = "select * from " + tbl_FunctionProduct.b_tbl_FunctionProduct + strAsc;
            return GetAll(strSQL, CommandType.Text);
        }

        protected override int InsertOnSubmit(tbl_FunctionProduct item, int t)
        {
            throw new NotImplementedException();
        }
    }
}
